home *** CD-ROM | disk | FTP | other *** search
/ Draw 3 / Draw 3.iso / AOL90 / COMP01.000 / %AFIXPATH% / 10094CNLUS.udp / out / closeaol.js < prev    next >
Encoding:
JavaScript  |  2004-10-13  |  9.6 KB  |  295 lines

  1. // ADP Auto Fix - Close AOL Script
  2. // Copyright (c) GTek Technologies Ltd.
  3.  
  4. //======== Declarations =================================================================
  5. var closeUtil = new closeAolUtil();
  6. var dispUtil = new userDisplay();
  7.  
  8. var excuteTimeout;
  9. var sLastEvent = "";
  10.  
  11. var bWaitMsg = false;
  12. var bStrauss;
  13. var bSysTray = false;
  14. var bStraussOnline = false;
  15. var bAbortedClose = false;
  16. var nApiCloseValid = 3;
  17. var nCmdResult;
  18.  
  19. var childProcess = new Array();
  20. childProcess[0] = "shellrestart.exe,true"; // Pixie Dust window
  21. childProcess[1] = "aolphx.exe,false";      // Schedual updates
  22.  
  23. //======== Close AOL Execution ==========================================================
  24.  
  25. function initCloseAOL() { // entry 
  26.    bStrauss = closeUtil.isAolStrauss();
  27.    g_oAdp.Vars("CurrentADP") = "initCloseAOL";
  28.    dispUtil.init();
  29. }
  30.  
  31. function runCloseAOL(sBrowserState) {
  32.    if (dispUtil.isValidPhase()) {
  33.       if (sBrowserState == "visible") {
  34.          closeUtil.closeBrowser();
  35.       } else {
  36.          runCloseChild();
  37.       }     
  38.    }
  39. }
  40.  
  41. function runCloseChild() {
  42.    clearTimeout(excuteTimeout); // systray close timeout
  43.    
  44.    if (isChildProcess())
  45.       excuteTimeout = setTimeout(runCloseChild, 4000);
  46.    else
  47.       setTimeout(finishClose, 3000);
  48. }
  49.  
  50. //======== Execution utils ==============================================================
  51.  
  52. function isChildProcess() {
  53.    return closeUtil.killProcessBatch(childProcess);
  54. }
  55.  
  56. function finishClose() {
  57.    
  58.    try {
  59.       clearTimeout(excuteTimeout);
  60.    } catch(e) {
  61.       //alert(e.description);
  62.    }
  63.       
  64.    if (closeUtil.isBrowserAlive()) {
  65.       closeUtil.closeBrowser();
  66.    } else {
  67.       if (dispUtil.isValidPhase()) {
  68.          g_oSys.getObj().StopWinWait(); // clears all events
  69.          dispUtil.setMsg("idCloseAOLWait2", false);
  70.          showScreen(idCloseAOLWait, {idBtnClose: dispUtil.goAbortRetry});
  71.          idCloseAOLWait.all.idBtnClose.style.display = "";
  72.          excuteTimeout = setTimeout(exitClose, 3000);
  73.       }
  74.    }
  75. }
  76.  
  77. function exitClose() { //create a smooth switch to the flow
  78.    dispUtil.setProgBarCss(true);
  79.    excuteTimeout = setTimeout(navigateFlow, 1000);
  80. }
  81.  
  82. //======== UI Util ======================================================================
  83.  
  84. function userDisplay() {
  85.  
  86.    this.init = function() { // checks if display is needed or move directly to flow
  87.       if (closeUtil.isBrowserAlive() || isChildProcess()) {
  88.          
  89.          if (bStrauss) {
  90.             if (bSysTray) {
  91.                this.setMsg("idCloseAOLWait2", false); //systray close
  92.             } else {
  93.                if (g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) != nApiCloseValid && !closeUtil.isOnline())
  94.                   this.setMsg("idCloseAOLWait3", false); //can't close client . verfing
  95.                else
  96.                   this.setMsg("idCloseAOLWait", false); //client full close
  97.             }
  98.          } else {
  99.             this.setMsg("idCloseAOLWait", false); //client full close
  100.          }
  101.          
  102.          
  103.          showScreen(idCloseAOLWait, {idBtnClose: dispUtil.goAbortRetry});
  104.          idCloseAOLWait.all.idBtnClose.style.display = "";
  105.          g_oSys.getObj().WaitForChildWindowCloseOrUnVisible("AOL","_AOL_Toolbar","",5000); 
  106.       } else {
  107.          finishClose();
  108.       }
  109.    };
  110.    
  111.    this.setProgBarCss = function(bHide) {
  112.       progObj = document.getElementById("ProgressBarContainer");
  113.       progObj.style.top = "180";
  114.       hideProgBar(bHide);
  115.    };
  116.    
  117.    this.setMsg = function(msgId, bHide) {
  118.       this.setProgBarCss(bHide);
  119.       idMsgCloseAOLWait.innerHTML = getDsoMsg(msgId);
  120.    };
  121.       
  122.    this.goAbortRetry = function() {
  123.       bAbortedClose = true;
  124.       g_oSys.getObj().StopWinWait(); // clears all events
  125.       
  126.       sLastEvent = "";
  127.       g_oAdp.Vars("sRequestClose") = "";
  128.       bWaitMsg = false;
  129.       bProbedClient = false;
  130.       nCmdResult = "";
  131.       
  132.       try {
  133.          clearTimeout(excuteTimeout);
  134.       } catch(e) {}
  135.    
  136.       g_oAdp.Vars("CurrentADP") = "goAbortRetry";
  137.       sendStat("Abort");
  138.       showScreen(idAbortRetry, {idBtnClose: chkExitWay, idBtnRestart: restartFix});
  139.    };
  140.    
  141.    this.isValidPhase = function() {
  142.       if (g_oAdp.Vars("CurrentADP").match(/goAbortRetry|goIntro|goEndAF/i) == null) 
  143.          return true;
  144.       else
  145.          return false;
  146.    };
  147.  
  148. }
  149.  
  150. //======== Close Process Util ===========================================================
  151.  
  152. function closeAolUtil() {
  153.  
  154.    this.killProcessBatch = function(sProcessBatch) { // closes / checks multiple process
  155.       bAliveOrTerminated = false; // sets return value
  156.       g_oProce.getObj().Exclude("%system%\\*"); // ignores process from %system%
  157.       g_oProce.getObj().Exclude("*%windows%*"); // ignores process from %windows%
  158.       g_oProce.getObj().Refresh;
  159.             
  160.       for (i=0;i<sProcessBatch.length;i++) {
  161.          // gets data from array
  162.          sThisProcess = sProcessBatch[i].substring(0, sProcessBatch[i].indexOf(","));
  163.          bTerminate = (sProcessBatch[i].substring(sProcessBatch[i].indexOf(",") + 1, sProcessBatch[i].length));
  164.             
  165.          // loop through the process list
  166.          for (a=0; a<g_oProce.getObj().Count; a++) {
  167.             sCurrentProcess = g_oProce.getObj().Process(a); // current process
  168.  
  169.             if (sThisProcess.toLowerCase() == sCurrentProcess.LongBaseName().toLowerCase()) { // checks current process name
  170.                if (bTerminate == "true")
  171.                   sCurrentProcess.Terminate(1,1000); // arguments force, time
  172.                      
  173.                bAliveOrTerminated = true;
  174.             }    
  175.          }
  176.       }
  177.       
  178.       return bAliveOrTerminated;
  179.    };
  180.    
  181.    this.closeBrowser = function() { // closes AOL client
  182.       
  183.       if (bStrauss) { // AOL Strauss close sequence
  184.          if (g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) == nApiCloseValid || (this.isOnline() && g_oAdp.Vars("sRequestClose") != "TRUE")) {
  185.             g_oAdp.Vars("sRequestClose") = "TRUE";
  186.             nCmdResult = g_oSys.getObj().SendMessage("_AOL_EXAPI","",3630,0,0);
  187.          }
  188.       } else { // all other AOL versions close sequence
  189.          if (g_oAdp.Vars("sRequestClose") != "TRUE") {
  190.             sLastEvent = "default"; // resets the flag after probing AOL
  191.             g_oAdp.Vars("sRequestClose") = "TRUE";
  192.             g_oSys.getObj().SendMessage("AOL Frame25","*",0x0112,0xf060,0);
  193.          }
  194.       }
  195.       
  196.       g_oSys.getObj().WaitForChildWindowCloseOrUnVisible("AOL","_AOL_Toolbar","",10000); // AOL Brw. internal window
  197.    };
  198.     
  199.    this.isBrowserAlive = function() {
  200.       if (g_oAol.getObj().IsAolBrowserOpen() || g_oSys.getObj().FindChildWindow("AOL Frame25","*")) 
  201.          return true;
  202.       else
  203.          return false;
  204.    };
  205.    
  206.    this.isAolStrauss = function() {
  207.       if (parseInt(g_oAol.getObj().AolMajor) >= 4184)
  208.          return true;
  209.       else
  210.          return false;
  211.    };
  212.    
  213.    this.isOnline = function() {
  214.       regDir = "Software\\America Online\\All";
  215.       
  216.       if (g_oReg.getObj().IsRegValue("Current", regDir, "topspeed.proxy.http")) {
  217.          sOnlineStr = g_oReg.getObj().String("Current", regDir, "topspeed.proxy.http");
  218.          
  219.          if (sOnlineStr.match(/ie3/i)) //aol offline
  220.             return false;
  221.          else //aol online
  222.             return true; 
  223.       } else { //aol offline
  224.          return false; 
  225.       }
  226. };
  227.  
  228.  
  229. }
  230.  
  231. //======== Aol window events (CallBacks) ================================================
  232.  
  233. function eventHandler(sEvent, sWindow) {
  234.    if (sWindow == "AOL_INTRO") { //intro text check
  235.       g_oSys.getObj().StopWinWait(); // clears all events
  236.       
  237.       if (sEvent == "hidden") { //hidden mode
  238.          bSysTray = true;
  239.          goIntro(true);
  240.       } else {
  241.          goIntro(false);
  242.       }
  243.    }
  244.    
  245.    if (dispUtil.isValidPhase()) {
  246.       if ((bStrauss && g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) == -1) && bWaitMsg) { // user closed AOL manually
  247.          bWaitMsg = false;
  248.          dispUtil.setMsg("idCloseAOLWait2", false);
  249.          g_oSys.getObj().WaitForChildWindowOpen("AOL_SYS","_AOL_EXAPI","",20000);
  250.          return;
  251.       }
  252.       
  253.       if (((sLastEvent == "visible" && sEvent != "visible") || (bStrauss && g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) == nApiCloseValid)) && bWaitMsg) {
  254.          bWaitMsg = false;
  255.          dispUtil.setMsg("idCloseAOLWait", false);
  256.       }
  257.       
  258.       if ((sEvent == "visible" && sLastEvent !="") || (bStrauss && !bWaitMsg && ((g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) != nApiCloseValid && g_oSys.getObj().SendMessage("_AOL_EXAPI","",3628,0,0) > 0 && !closeUtil.isOnline()) || (closeUtil.isOnline() && g_oAdp.Vars("sRequestClose") == "TRUE" && nCmdResult != nApiCloseValid)) )){
  259.          bWaitMsg = true;
  260.          dispUtil.setMsg("idCloseAOL", true);
  261.       }
  262.          
  263.       runCloseAOL(sEvent);
  264.       sLastEvent = sEvent;
  265.    }
  266. }
  267.  
  268. function sysTrayHandler(sState) {
  269.    if (dispUtil.isValidPhase()) {
  270.       if (sState == "visible")
  271.          runCloseAOL("visible");
  272.       else
  273.          eventHandler("closed");
  274.    }
  275. }
  276.  
  277. function AdpSys_WaitForCloseOk(sValue) {
  278.    eventHandler("closed", sValue);
  279. }
  280.  
  281. function AdpSys_WaitForUnVisibleOk(sValue) {
  282.    eventHandler("hidden", sValue);
  283. }
  284.  
  285. function AdpSys_WaitForCloseTimeOut(sValue) {
  286.    eventHandler("visible", sValue);
  287. }
  288.  
  289. function AdpSys_WaitForOpenOk(sValue) { // AOL Strauss related, waits for systray to re-pop
  290.    sysTrayHandler("visible", sValue);
  291. }
  292.  
  293. function AdpSys_WaitForOpenTimeOut(sValue) {
  294.    sysTrayHandler("closed", sValue);
  295. }